import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { BaseItem } from "../common/BaseItem";
import { Language } from "../../../../extend/language/Language";
import { SNewLoginBackRewardInfo } from "../../../../Message/Game/SNewLoginBackRewardInfo";
import { ItemData } from "../../resource/info/ItemData";
import { LoginBackRewardData } from "./LoginBackRewardData";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
import { GButton } from "../../../../com/mui/controls/GButton";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
//class AllRewardRenderer
    
    export  class AllRewardRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._bg = ObjCreate.createBg(0, 0, 117, 130, this, ImagesConst.RechargeBottom);
            this._nameBg = ObjCreate.createBg(0, 2, 117, 25, this, ImagesConst.FightingStrgBg);
            var loc1=new GTextFormat("", 14, 16771647, true, null, null, null, null, flash.text.TextFormatAlign.CENTER);
            this._nameTxt = ObjCreate.createTextField("", 0, 3, 117, 25, this, loc1);
            this._itemBg = ObjCreate.createBg(26, 30, 64, 64, this, ImagesConst.PackItemBg);
            this._baseItem = new BaseItem();
            this._baseItem.move(28, 32);
            this._baseItem.setSize(60, 60);
            this._baseItem.isDragAble = false;
            this._baseItem.isDropAble = false;
            addChild(this._baseItem);
            this._getBtn = ObjCreate.createGButton(Language.getString(20146), 33, 100, 50, 25, this, "ButtonRed");
            this._getBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onGetBtnClickHandler);
            this._getBtn.enabled = false;
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=0;
            super.data = arg1;
            if (arg1 && arg1 is SNewLoginBackRewardInfo) 
            {
                this._rewardInfo = arg1 as SNewLoginBackRewardInfo;
                this._baseItem.itemData = new ItemData(this._rewardInfo.itemCode);
                this._nameTxt.htmlText = Language.getStringByParam(36533, this._rewardInfo.pos);
                loc1 = LoginBackRewardData.instance.totalDays;
                if (this._rewardInfo.getFlag == 0) 
                {
                    if (this._rewardInfo.getFlag == 0 && this._rewardInfo.pos > loc1) 
                    {
                        this._getBtn.enabled = false;
                    }
                    else 
                    {
                        this._getBtn.enabled = true;
                    }
                }
                else 
                {
                    this._getBtn.label = Language.getString(20152);
                    this._getBtn.enabled = false;
                }
                this._getBtn.drawNow();
            }
            return;
        }

        /* internal  */onGetBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._rewardInfo) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.LoginBackToGetTotalReward, this._rewardInfo.pos));
            }
            return;
        }

        protected /* var */_bg: ScaleBitmap;

        protected /* var */_itemBg: ScaleBitmap;

        protected /* var */_nameBg: ScaleBitmap;

        protected /* var */_baseItem: BaseItem;

        protected /* var */_getBtn: GButton;

        protected /* var */_nameTxt: GTextFiled;

        /* internal */ /* var */_rewardInfo: SNewLoginBackRewardInfo;
    }
